package com.yx.doodleview.ui.widget.doodleveiw.action;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;

/**
 * Created by yx on 2017/8/21.
 */

public class PathAction extends BaseAction {
    private Path path;
    private int width;


    public PathAction(float touchX, float touchY, int width, int color) {
        super(color);
        this.width = width;
        path = new Path();
        path.moveTo(touchX, touchY);
    }


    @Override
    public void draw(Canvas canvas) {
        Paint mPaint = new Paint();
        mPaint.setColor(color);
        mPaint.setAntiAlias(true);
        mPaint.setStrokeWidth(width);
        mPaint.setStyle(Paint.Style.STROKE);
        canvas.drawPath(path, mPaint);
    }

    @Override
    public void move(float x, float y) {
        path.lineTo(x, y);
    }
}
